package com.njwb.day05;

public class People1 {
    private String name;
    private boolean gender;
    private People1 spouse;



    public People1(String name, boolean gender) {
        this.name = name;
        this.gender = gender;
    }


    public void marry(People1 people1){
        if (this.spouse==null&& people1.spouse==null&&this.gender!= people1.gender){
this.spouse= people1;
people1.spouse=this;
            System.out.println(this.name+"与"+ people1.name+"结婚成功！");
        }
    else if (this.spouse!=null){
            System.out.println(this.name+"与"+this.spouse.name+"已经结婚,不能再与"+ people1.name+"结婚");
        }
     else if(people1.spouse!=null){
            System.out.println(people1.name+"与"+ people1.spouse.name+"已经结婚不能再与"+this.name+"结婚");
        }
     else if(this.gender== people1.gender){
            System.out.println("同性不能结婚");
        }


}
}
